/*
 * Instance.cpp
 *
 *  Created on: Jan 15, 2012
 *      Author: luiz
 */

#include "Instance.h"

Instance::Instance()
{
    layer_default_ = NULL;
    truth_table_ = new TruthTable(0,0);
    entry_table_ = new TruthTable(0,0);

    description_= "";
    file_name_ = "";
    number_of_cells_ = 0 ;
    number_of_positions_occupied_by_cell_ = 0;
}

Instance::~Instance()
{
    if(layer_default_ !=NULL){
        delete layer_default_;
        delete truth_table_;
        delete entry_table_;
    }
}



Instance Instance::operator =(Instance & instance)
{
    if(this != & instance){
        if(this->truth_table_!=NULL){
            delete this->truth_table_;
            truth_table_ = NULL;
        }
        this->truth_table_ = new TruthTable(*instance.truth_table_);

        if(this->entry_table_!=NULL){
            delete this->entry_table_;
            entry_table_ = NULL;
        }
        this->entry_table_ = new TruthTable(*instance.entry_table_);

        if(this->layer_default_!=NULL){
            delete this->layer_default_;
            layer_default_ = NULL;
        }
        this->layer_default_ = new Layer(*instance.layer_default_);

        this->number_of_cells_ = instance.number_of_cells_;
        this->number_of_positions_occupied_by_cell_ = instance.number_of_positions_occupied_by_cell_;
        this->description_ = instance.description_;
        this->file_name_ = instance.file_name_;
        this->evaluation_function_ = instance.evaluation_function_;

    }
    return *this;
}


Instance::Instance(const Instance & instance)
{
    this->truth_table_ = new TruthTable(*instance.truth_table_);
    this->entry_table_ = new TruthTable(*instance.entry_table_);
    this->layer_default_ = new Layer(*instance.layer_default_);
    this->number_of_cells_ = instance.number_of_cells_;
    this->number_of_positions_occupied_by_cell_ = instance.number_of_positions_occupied_by_cell_;
    this->description_ = instance.description_;
    this->evaluation_function_ = instance.evaluation_function_;
    this->file_name_ = instance.file_name_;
}


int Instance::num_outputs()
{
    return truth_table_->num_outputs();
}


int Instance::number_inputs()
{
    return truth_table_->num_inputs();
}

int Instance::number_of_positions_occupied_by_cell() const
{
    return number_of_positions_occupied_by_cell_;
}



void Instance::set_number_of_positions_occupied_by_cell(int num)
{
    number_of_positions_occupied_by_cell_ = num;
}

int Instance::number_of_cells()
{
    return number_of_cells_;
}



void Instance::set_number_of_cells(int number)
{
    number_of_cells_ = number;
}

void Instance::set_description(std::string description)
{
    description_ = description;
}



std::string Instance::description()
{
    return description_;
}

void Instance::set_layer_default(Layer & layer_default)
{
    layer_default_ = new Layer(layer_default);
}



Layer* Instance::get_layer_default()
{
    return layer_default_;
}

TruthTable *Instance::truth_table()
{
    return truth_table_;
}


Layer Instance::get_layer_default() const
{
    return *layer_default_;
}

void Instance::set_truth_table(const TruthTable & truth_table)
{
    *truth_table_ = truth_table;
}

TruthTable *Instance::entry_table()
{
    return entry_table_;
}



void Instance::set_entry_table(const TruthTable & entry_table)
{
    *entry_table_ = entry_table;
}

EvaluationFunction *Instance::evaluation_function()
{
    return evaluation_function_;
}


void Instance::set_evaluation_funcion(EvaluationFunction * evaluation)
{
    this->evaluation_function_ = evaluation;
}

std::string Instance::file_name()
{
    return file_name_;
}



void Instance::set_file_name(const std::string & file_name)
{
    file_name_ = file_name;
}

























